{
	load_mod('userinfo');
	load_mod('message');
	load_mod('pager');
	load_mod('showEmotion');


	//以下是评论
	$('#cmt_cmtSubmit').click(function(){
		content = $('#cmt_cmtInput').val();
		
		if(content.length==0){
			console.log('xx');
			$('#cmt_cmtAlert').text('请输入评论内容');
			return false;
		} else if(content.length > 140){
			$('#cmt_cmtAlert').text('评论太长了呀，亲！');
			return false;
		}


		postdata = 'rid='+scope.$rid
		+'&content='+content
		;
		$.post('/riaapi/comment/aj_comment.php',postdata , function(data){
            eval("data="+data);
            if(data.code=="A00006")
            {
            	$('#cmt_cmtComid').val('');
				$('#cmt_cmtInput').val('');

                cmt_loadComment(1);
            }
            else
            {
                
            }
        });
	});

	

	function cmt_loadComment( page )
	{
		$.getJSON(
			'/riaapi/comment/aj_getComment.php?page='+page+'&rid='+scope.$rid,
			'',
			function(data){
				if(data.code == 'A00006')
				{
					if(data.data.html)
					{
						$('#cmt_cmtList').html(data.data.html);
					}else{
						$('#cmt_cmtList').html('<div style="padding:20px;text-align: center;vertical-align: middle;">都安静了？快来发第一条评论吧~~</div>');
					}
					$('#cmt_cmtPager').html(show_pager('cmt_cmtDoPage' , page , data.data.pageNum));

					//绑定分页事件
					$('a.cmt_cmtDoPage').click(function(){
						cmt_loadComment($(this).attr('page'));
					});

					bindreply();
				}
				
			});
	}

	function bindreply()
	{
		$('a.cmt_cmtRpl').click(function(){
			console.log('x');
			$('#cmt_cmtComid').val($(this).attr('cmtid'));
			$('#cmt_cmtInput').val('回复@'+$(this).attr('nick')+' :');
		});
	}

	cmt_loadComment(1);
	show_emotion('cmt_cmtEmotion' , 'cmt_cmtInput');
}